<template>
	<view class="boxs">
		<view class="cu-bar bg-white flex_op nav">
			<navigator open-type="navigateBack">
				<view class="action"><text class="cuIcon-back text-gray"></text> 返回</view>
			</navigator>
			<view class="content text-bold">上传头像</view>
			<view class="baoc" @click="modalName='bottomModal'">上传</view>
		</view>

		<view class="imt ">
			<view class="tex">
				<view class="tit bold">报名照图像要求： </view>
				<view class="ali-c"><view class="icon"></view>彩色个人标准大头照，能反映出您当前的面貌 </view>
				<view class="ali-c"><view class="icon"></view>脸部正对相机拍摄的，面部表情平和，双眼睁开 </view>
				<view class="ali-c"><view class="icon"></view>不能佩戴掩盖头发或发际线的帽子，整张脸必须 是可见 </view>
				<view class="ali-c"><view class="icon"></view>如果你平时戴眼镜（有色隐形眼镜除外），拍摄 时无需摘除，但眼镜上的反光不能出现在照片中 </view>
				<view class="tit bold">照片上传格式要求： </view>
				<view class="ali-c">
					<view class="icon jus-e"></view>
					尺寸：可接受的最低尺寸为600×600像素；可接 受的最大尺寸为1200×1200像素。
				</view>
				<view class="ali-c"><view class="icon"></view>眼距：两眼间距不小于60像素，建议90像素以上 </view>
				<view class="ali-c"><view class="icon"></view>建议尺寸：2M以内</view>
			</view>
			<view class="flexc avat">
				<avatar
					selWidth="300px" selHeight="300px"  ref='avatar' fileType='png'
					:avatarSrc="ults.userPicturePath?ults.userPicturePath:url" @upload="myUpload" quality="1" inner=true
					avatarStyle="width: 300px; height: 300px;">
				</avatar>
			</view>
			
		</view>
		
		<!-- 头像弹窗 -->
		<view class="cu-modal bottom-modal" :class="modalName=='bottomModal'?'show':''">
			<view class="cu-dialog">
				<view class="paddingxl">
					<view class="flexc" @click="clk">上传照片</view>
					<!-- <view class="flexc" @click="paizhao(int=2)">从相册中选择</view> -->
					<view class="qux flexc" @click="modalName=null">取消</view>
				</view>
			</view>
		</view>
		<view v-if="loadModal" class="MaskLayer"></view>
		<view class="gif" v-if="loadModal">
			<view>
				<image src="http://oos-cn.ctyunapi.cn/hfclass/jiazai.gif?Signature=OgNX%2BUIeALb4HM35vCGC1jX%2BZEw%3D&AWSAccessKeyId=65b300139cc5a0aa9572&Expires=865585100785"></image>
				<view>请耐心等待！</view>
			</view>
		</view>
	</view>
</template>

<script>
	import App from '../../App.vue'
	import avatar from "../component/yq-avatar/yq-avatar.vue";
	export default {
		components: {avatar},
		data() {
			return {
				userId:'',
				loadModal: false,
				ults:'',
				modalName:null,
				
				urls: ["../../static/tabbar/txs.png","../../static/tabbar/txs.png"],
				url:"../../static/tabbar/txs.png"
				
			}
		},
		onLoad( op) {
			var that=this
		
			if(op.id){
				that.userId=op.id
				that.gettouxiang()
			}
			// else{
			// 	if(this.userId==0||this.userId==null||this.userId==''||this.userId==undefined){
			// 		this.gitObj()
			// 	}
			// }
			
		},
	
		methods:{
			clk() {
				this.modalName=null
				let avatar = this.$refs.avatar;
				avatar.fChooseImg(1, {selWidth: "300px", selHeight: "300px", expWidth: "300px", expHeight: "300px", inner:false}, {data: 'xxx'});
			},
			myUpload(rsp) {
				var that=this
				that.loadModal=true
				uni.request({
					method:'POST',
					url:App.globalData.baseUrl + '/api/services/app/organUser/ModifyPhoto',
					data:{
						"base64": rsp.base64,
						"userId": that.userId
					},
					success(res) {
						that.loadModal=false
						if(res.data.success==true){
							uni.showToast({
								title:'头像上传成功',
								duration:2000,
								icon:'none'
							})
							that.gettouxiang()
						}
					}
				})
				
			},
			gettouxiang(){
				var that=this
				uni.request({
					method:'POST',
					url:App.globalData.baseUrl + '/api/services/app/organUser/GetUserInfo',
					data:{
						 "userId":that.userId,
					}, success(res) {
						if(res.data.success==true){
							that.ults=res.data.result
						}
					}
				})
			},
			// gitObj(){
			// 	var that=this
			// 	that.loadModal=true
			// 	uni.request({
			// 		method:'POST',
			// 		url:App.globalData.baseUrl + '/api/services/app/session/GetCurrentLoginInformations',
			// 		success(res) {
			// 			if(res.data.result==null||res.data.result.user==undefined||res.data.result.user==null||res.data.result.user==''){
			// 				that.loadModal=false
			// 				uni.showToast({
			// 					icon:'none',
			// 					duration:2000,
			// 					title:'未登录'
			// 				})
			// 				let cl=setTimeout(()=>{
			// 					window.location.href='/wx/GetCode'
			// 					clearTimeout(cl)
			// 				},2000)
			// 			}else{
			// 				that.userId=res.data.result.user.id
			// 				that.getonlon()
			// 			}
			// 		},fail(res) {
			// 			that.loadModal=false
			// 			uni.showToast({
			// 				title:res.data.error.message,
			// 				duration:1000,
			// 				icon:'none'	,
			// 			})
			// 		}
			// 	})
			// }
		}
	}
</script>

<style scoped>
	/* page{background-color: #000000;} */
	.boxs{width: 100%;}
	.nav{padding:0 30rpx; height: 100rpx;}
	.baoc{color: #0081FF;}
	.cu-bar .action:first-child {
	    margin-left: 0px;
	}
	.imt{
		width: 100%;
		height: 100%;
		padding: 0 30rpx;
	}
	.imt>image{
		width: 100%;
		height: 760rpx;
	}
	.paddingxl>view{
		height: 100rpx;
	}
	.paddingxl .qux{
		height: 110rpx;
		border-top: 20rpx solid #F3F3F3;
	}
	.tex>.tit{margin-top: 30rpx;}
	.tex>view{
		margin-top: 20rpx;
		font-size: 26rpx;
	}
	.icon{
		width: 7rpx;
		height: 7rpx;
		background-color: #000000;
		border-radius: 60%;
		margin: 0 10rpx;
	}
	.avat{margin-top: 100rpx;}
</style>
